// base
import Taro, { Component } from '@tarojs/taro'
import { View, Image } from '@tarojs/components'
// less
import './index.less'

class MessageRadioWrap extends Component {
  componentWillMount () {
    // onLoad
  }

  componentDidMount () {
    // onready
  }

  componentDidShow () {
    // onshow
  }

  componentDidHide () {
    // onhide
  }

  componentWillUnmount () {
    // onUnload
  }

  componentWillReceiveProps () {}

  delay (time = 0) {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve()
      }, time)
    })
  }

  onChange = current => {
    this.setState({
      current
    })
    this.props.onChange({ current })
  }

  render () {
    const { value, dataSource } = this.props
    return (
      <View className="MessageRadioWrap_id22561">
        <View className="title">{this.props.name}</View>
        <View className="sexwrap">
          <Image
            className="sex-img"
            src={
              value == dataSource[0].value
                ? 'https://imagesize.hrwork.com/sp/files/9d261d62-60cd-482d-8af1-15cc38812d7f.png'
                : 'https://imagesize.hrwork.com/sp/files/7681e07f-7abf-4e9a-b51b-f99d9604931c.png'
            }
            onClick={this.onChange.bind(this, dataSource[0].value)}
          />
          <View className="line"></View>
          <Image
            className="sex-img"
            src={
              value == dataSource[1].value
                ? 'https://imagesize.hrwork.com/sp/files/f3128313-9578-4cc6-a7df-c5c9c7f34ae2.png'
                : 'https://imagesize.hrwork.com/sp/files/e97df3f7-ec94-412c-bbad-0380f6bea26f.png'
            }
            onClick={this.onChange.bind(this, dataSource[1].value)}
          />
        </View>
      </View>
    )
  }
}

export default MessageRadioWrap
